import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-01-10
 * Time: 12:27
 */
public class test1 {
    /*
    LeetCode 205 同构字符串
     */


    // 哈希表
    public boolean isIsomorphic(String s, String t) {
        Map<Character,Character> ss = new HashMap<Character,Character>();
        Map<Character,Character> tt = new HashMap<Character,Character>();
        int n = s.length();
        for(int i=0;i<n;i++){
            char x = s.charAt(i);
            char y = t.charAt(i);
            if((ss.containsKey(x) && ss.get(x)!=y) || (tt.containsKey(y) && tt.get(y)!=x)){
                return false;
            }
            ss.put(x,y);
            tt.put(y,x);
        }
        return true;
    }
}
